#!/usr/bin/env python

import time
import random

LFSFS = '/home/usmanm/fuse'
FUSEFS = '/home/usmanm/xmp/home/usmanm'
EXT3FS = '/home/usmanm/local'

NOOFBYTES = 100000
NOOFITER = 1000

def create_files():
    f_lfs = open(LFSFS + '/hello', 'w')
    f_fuse = open(FUSEFS + '/hello', 'w')
    f_ext3 = open(EXT3FS + '/hello', 'w')

    # Write ~100k to each file
    for i in range(100000):
        r = random.randint(0, 9)
        f_lfs.write(str(r))
        f_fuse.write(str(r))
        f_ext3.write(str(r))

    f_lfs.close()
    f_fuse.close()
    f_ext3.close()

def main():
    create_files()

    start = time.time()
    for j in range(NOOFITER):
        f = open(LFSFS + '/hello')
        f.read(NOOFBYTES) 
        f.close()
    print 'LFS: ' + str(time.time() - start)

    start = time.time()
    for j in range(NOOFITER):
        f = open(FUSEFS + '/hello')
        f.read(NOOFBYTES) 
        f.close()
    print 'FUSE: ' + str(time.time() - start)

    start = time.time()
    for j in range(NOOFITER):
        f = open(EXT3FS + '/hello')
        f.read(NOOFBYTES) 
        f.close()
    print 'Ext3: ' + str(time.time() - start)


if __name__ == '__main__':
    main()
